package com.nineclock.message.config;

import com.nineclock.message.pojo.NcMessage;
import com.nineclock.message.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RocketMQMessageListener(topic = "messagePushTopic", consumerGroup = "messagePushConsumer33")
public class MsgConsumerListener implements RocketMQListener<NcMessage> {
    @Autowired
    MessageService messageService;

    @Override
    public void onMessage(NcMessage message) {
        log.info(message.getApplyUsername() + "申请加入企业, 推送给" + message.getApproveUsername() +"审批");
        try {
            messageService.pushSingleMessage(message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}